package com.kb.design.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kb.design.common.ApiResponse;
import com.kb.design.common.ResponseObject;
import com.kb.design.entity.DesignTalk;
import com.kb.design.service.DesignTalkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/talk")
public class DesignTalkController {

    @Autowired
    private DesignTalkService designTalkService;

    /**
     *
     * @param
     * @param
     * @return
     */
    @PostMapping("/pageList")
    public ApiResponse getBonusConfigByConditionWithJoin(@RequestBody DesignTalk designTalk) {
        Page<DesignTalk> page = new Page<>(designTalk.getPage(), designTalk.getPerPage());
        ResponseObject responseObject = new ResponseObject();

        Page<DesignTalk> designTalkPage = designTalkService.pageList(page, designTalk);
        responseObject.setItems(designTalkPage.getRecords());
        responseObject.setTotal(designTalkPage.getTotal());
        return ApiResponse.success(responseObject);
    }
    /**
     *
     * @param
     * @return
     */
    @PostMapping("/save")
    public ApiResponse saveBonusConfig(@RequestBody DesignTalk designTalk) {
        return ApiResponse.success(designTalkService.save(designTalk));
    }
    /**
     *
     * @param
     * @return
     */
    @PostMapping("/del")
    public ApiResponse del(@RequestBody DesignTalk designTalk) {
        return ApiResponse.success(designTalkService.del(designTalk));
    }

}
